<%@ page language="java" errorPage="/error.jsp" pageEncoding="UTF-8" contentType="text/html; charset=utf-8" %>
<%@include file="/quick/include/common.jsp"%>
<script>

function _check(rec){
  var check="";
  if(Ext.isEmpty(rec)){
     check=Ext.get('_NOTE_STATUS').getValue();
  }else{
    check=rec.get('NOTE_STATUS');
  }
  if(check=="CHECKED"){
    Ext.Msg.alert('<fmt:message key="label.error"/>','单据已审核,单据及单据产品已不可再操作!');
    return false;
  }
  return true;
}

function _audit(noteId){
    if(_check()==false) return;
		Ext.Msg.confirm('<fmt:message key="label.info"/>','审核出入单据将修改库存,确认审核吗?',function(btn){
		   	 if(btn=='yes'){
				 Ext.Ajax.request({
				   method:'POST',
				   url:"<c:url value='/ajax/stock/note/warehouseNoteAudit.html'/>",
				   success: function(response){
				                 var resp=Ext.decode(response.responseText);
						         Ext.Msg.alert('<fmt:message key="label.info"/>',resp.info,function(){
						            if(resp.result=='success'){
							         	Ext.get('_NOTE_STATUS').dom.innerText='已审核';
							         	Ext.get('_NOTE_STATUS').dom.value='CHECKED';
						         	}
						         });
						        },
				   failure: function(){
						          Ext.Msg.alert('<fmt:message key="label.error"/>','<fmt:message key="info.save_error"/>');
						      },
				   params:{'noteId':noteId}
				}); 
		     }	
		});    
 
}  
</script>
